package com.jd.sunny.java.collection;

import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * @Description:implemnt Comparable,so wo can compare Item
 * @author:sunlin
 * @since:2012-12-05 18:16
 * @version:1.0.0
 */
public class Item implements Comparable<Item>{

    private String name;
    private int priority;

    /**
     * second method to compare
     * @param o
     * @return
     */
    public int compareTo(Item o) {
//        if(o == null){                                  //this object is big
//            return 1;
//        } else if(this.name.equalsIgnoreCase(o.getName())){    //equal
//            return 0;
//        }else if(){
//            return -1;
//        }
        return this.name.compareTo(o.getName());
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}
